const auth ={
	getOpenidAndUserinfo(code) {
		uni.request({
			url: 'http://www.mksoft.cn/zx/front/wx/getUserInfo',
			data: {
				code: code
			},
			success: res => {
				if (res.data.code == 200) {
					this.userInfo.avatar = res.data.data.headimgurl;
					this.userInfo.nickName = res.data.data.nickname;
					this.userInfo.openid = res.data.data.openid;
					this.userInfo.sex = res.data.data.sex;
					uni.setStorageSync("h5_wx_code",this.userInfo)
					if(this.routePath){
						this.$Router.push(this.routePath)
					}
				} else if (res.data.data.code == 400) {
					// token已过期，需要重新授权
					this.getWxCode();
				}
			},
			fail: res => {
				uni.showToast({
					title: '获取用户信息失败',
					icon: 'none',
					duration: 2500
				});
			}
		});
	},
	
}
export default auth